# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=wiringpi
pkgver=2.46
_commitid=8d188fa0e00bb8c6ff6eddd07bf92857e9bd533a
pkgrel=2
pkgdesc="command line interface for Raspberry Pi gpio"
url="http://wiringpi.com/the-gpio-utility/"
arch="aarch64 armhf armv7"
license="LGPL-3.0"
options="!check" # no testsuite
depends=""
makedepends="linux-headers"
install=""
subpackages="$pkgname-dev"
source="wiringpi-$pkgver.tar.gz::https://github.com/WiringPi/WiringPi/archive/$_commitid.tar.gz
	"

builddir="$srcdir"/WiringPi-$_commitid

build() {
	cd "$builddir"
	make -C wiringPi CFLAGS="$CFLAGS -fpic -I." LDFLAGS="$LDFLAGS" WIRINGPI_SONAME_SUFFIX=".$pkgver"
	ln -sf libwiringPi.so.$pkgver wiringPi/libwiringPi.so
	make -C devLib CFLAGS="$CFLAGS -fpic -I../wiringPi" LDFLAGS="$LDFLAGS" WIRINGPI_SONAME_SUFFIX=".$pkgver"
	ln -sf libwiringPiDev.so.$pkgver devLib/libwiringPiDev.so
	make -C gpio CFLAGS="$CFLAGS -I../wiringPi -I../devLib" LDFLAGS="$LDFLAGS -L../wiringPi -L../devLib"
}

package() {
	cd "$builddir"
	install -d -m755 "$pkgdir"/usr/include
	install -D -m644 wiringPi/*.h devLib/*.h "$pkgdir"/usr/include
	install -D -m755 wiringPi/libwiringPi.so."$pkgver" "$pkgdir"/usr/lib/libwiringPi.so."$pkgver"
	ln -s libwiringPi.so."$pkgver" "$pkgdir"/usr/lib/libwiringPi.so
	install -D -m755 devLib/libwiringPiDev.so."$pkgver" "$pkgdir"/usr/lib/libwiringPiDev.so."$pkgver"
	ln -s libwiringPiDev.so."$pkgver" "$pkgdir"/usr/lib/libwiringPiDev.so
	install -D -m755 gpio/gpio "$pkgdir"/usr/bin/gpio
}

sha512sums="eae4868a25a08ab9b7207548111f3a50dbd3b8ab85dd4d1b8c1da567253cbafa260ffdfc6bef78795dbce1c1c46f27d998a0c3f8302a7765d26519120cf306d1  wiringpi-2.46.tar.gz"
